package edu.dailicious.tapestryboard.pages.select;

import java.util.ArrayList;
import java.util.List;

import org.apache.tapestry5.OptionModel;
import org.apache.tapestry5.PersistenceConstants;
import org.apache.tapestry5.SelectModel;
import org.apache.tapestry5.ValueEncoder;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.internal.OptionModelImpl;
import org.apache.tapestry5.internal.SelectModelImpl;

import edu.dailicious.tapestryboard.encoder.IntegerValueEncoder;

public class SelectOptionModel {
	
	@Persist(PersistenceConstants.FLASH)
	@Property
	private Integer price;
	
	protected List<OptionModel> getOptionsModel(){  
		
		OptionModelImpl apple = new OptionModelImpl("Apple($1)", new Integer(1)); 		  
		OptionModelImpl manggo = new OptionModelImpl("Manggo($5)",new Integer(5)); 		  
		OptionModelImpl banana = new OptionModelImpl("Banana($10)", new Integer(10));  
		  
		List<OptionModel> optionsModel = new ArrayList<OptionModel>();  
		optionsModel.add(apple);  
		optionsModel.add(manggo);  
		optionsModel.add(banana);  
		
		return optionsModel;
	}
	
	public SelectModel getFruitModel() {  
	    return new SelectModelImpl(null, getOptionsModel());  
	} 
	
	public ValueEncoder<Integer> getValueEncoder(){  
	    return new IntegerValueEncoder();  
	}
	
	
}
